<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增地址簿')" />
    <link th:href="@{/static/css/city-picker/city-picker.css}" rel="stylesheet" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-custAddr-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">地址ID：</label>
                <div class="col-sm-8">
                    <input name="addrId" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">客户代码：</label>
                <div class="col-sm-8">
                    <input name="customerId" id="customerId" class="form-control" type="text" onclick="checkCustomer()" required readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">姓名：</label>
                <div class="col-sm-8">
                    <input name="userName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">联系方式：</label>
                <div class="col-sm-8">
                    <input name="userTele" id="userTele" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">省市区：</label>
                <div class="col-sm-8">
                    <input name="userArea" class="form-control" type="text"  data-toggle="city-picker">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">详细地址：</label>
                <div class="col-sm-8">
                    <input name="userAddress" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:src="@{/static/js/cityPicker/city-picker.data.js}"></script>
    <script th:src="@{/static/js/cityPicker/city-picker.js}"></script>
    <script type="text/javascript">
        var prefix = ctx + "bus/custAddr"
        $("#form-custAddr-add").validate({
            focusCleanup: true,
            rules:{
                userTele:{
                    isPhone:true,
                }
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-custAddr-add').serialize());
            }
        }

        //选择客户代码页面
        function checkCustomer() {
            $.modal.open("选择客户信息", prefix+"/chooseCust");
        }
        //选中客户代码
        function checkedCustomer(customerId) {
           $('#customerId').val(customerId);
        }

    </script>
</body>
</html>